

package io.renren.modules.job.task.clear;

import io.renren.modules.clearing.service.ETCTransactionUploadService;
import io.renren.modules.job.task.ITask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component("etcTransactionUploadTask")
public class ETCTransactionUploadTask implements ITask {
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	ETCTransactionUploadService etcTransactionUploadService;


	@Override
	public void run(String params){

		logger.info("etcTransactionUploadTask 定时任务正在执行，参数为：{}", params);
		List<String> netIDList =  new ArrayList<>();
		try {
			netIDList = etcTransactionUploadService.ETCTransactionUpload();
		}catch (Exception e){
			logger.info("ETC交易上传上传获取待上传发行方列表异常，任务退出");
			e.printStackTrace();
		}
			if(netIDList!=null&&netIDList.size()>0){
				for (int i = 0; i < netIDList.size(); i++) {
					try {
						etcTransactionUploadService.SendMsg(netIDList.get(i));
					} catch (Exception e) {
						e.printStackTrace();
						logger.info("上传发行方数据失败："+e.getMessage());
					}
				}

			}else{
				logger.info("任务暂停，或是没有待上传的数据");
			}
		logger.info("ETC交易上传上传结束");

	}
}
